<template>
  <div class="medcode-m">
    <el-header>
      <img src="../assets/navtop-b.png" alt="" width="100%">
    </el-header>
    <div class="info-wrap">
      <div class="trace-info">
        <h3>追溯码信息</h3>
        <table class="table-trace">
          <tr>
            <td>追溯码id</td>
            <td v-text="this.traceData.code"></td>
          </tr>
          <tr>
            <td>创建日期</td>
            <td v-text="this.traceData.created_at"></td>
          </tr>
          <tr>
            <td>药品名</td>
            <td v-text="this.traceData.drug.common_name"></td>
          </tr>
        </table>
      </div>
      <div class="drug-info">
        <h3>药品信息</h3>
        <table class="table-trace">
          <tr>
            <td>药品名</td>
            <td v-text="this.traceData.drug.common_name"></td>
          </tr>
          <tr>
            <td>药品id</td>
            <td v-text="this.traceData.drug.id"></td>
          </tr>          
          <tr>
            <td>生产日期</td>
            <td v-text="this.traceData.drug.created_at"></td>
          </tr>

        </table>
      </div class="trace-steps">
      <div class="drugs-location">
        <h3>流通信息</h3>
        <el-steps :active="2" direction="vertical">
          <el-step title="生产企业" icon="iconfont icon-ti-factory" description="生产企业   2017-11-14    13:39:00 上海"></el-step>
          <el-step title="流通企业" icon="iconfont icon-ti-enterprise" description="流通企业   2017-11-15   14:45:00 上海"></el-step>
          <el-step title="杭州中转站" icon="iconfont icon-ti-exchange" description="杭州中转站    2017-11-16 13:47:00 杭州"></el-step>
          <el-step title="零售企业" style="max-width:100%!important;" icon="iconfont icon-ti-shop" description="零售企业"></el-step>
        </el-steps>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        traceData: '',
        adminToken: "YWRtaW46Zm9kYWFpMTIz"
      }
    },
    mounted() {
      this.$http({
        url: '/trace-code/80001023041021203344/',
        methods: 'get',
        headers: {
          'Authorization': 'Basic ' + this.adminToken
        },
      }).then(response => {
        this.traceData = response.data
        console.log(response.data)
      }).catch(error => {
        if (error.response) {
          // The request was made and the server responded with a status code
          // that falls out of the range of 2xx
          console.log(error.response.data);
          // console.log(error.response.status);
          // console.log(error.response.headers);
        } else if (error.request) {
          console.log(error.request);
        } else {
          console.log('Error', error.message);
        }
        // console.log(error.config);
        this.$message({
          message: '查询失败',
          showClose: true,
          type: 'error'
        });
      });
    }
  }

</script>

<style scoped>
  .medcode-m {
    width: 100%;
    height: 100%;
    overflow: scroll;
  }

  .el-header {
    background: white;
  }

  .info-wrap {
    background: white;
    margin: 20px 20px 0;
    padding: 20px 20px 0;
    overflow: scroll;
  }

  h3 {
    text-align: left;
    margin: 5px 0;
    color: #4090c7
  }

  .drug-info {
    margin: 20px 0px;
  }

  .trace-steps {
    max-height: 300px;
    border: 1px solid grey;
  }

  .el-steps {
    height: 300px;
    overflow: hidden;
  }

  .table-trace {
    width: 100%;
  }

  .medcode-m>>>.is-finish {
    color: rgb(149, 170, 109);
    border-color: rgb(149, 170, 109);
  }

  .medcode-m>>>.is-process {
    color: #4090c7;
    border-color: #4090c7;
  }
  /* Border styles */

  .table-trace thead,
  .table-trace tr {
    border-top-width: 1px;
    border-top-style: solid;
    border-top-color: rgb(235, 242, 224);
  }

  .table-trace {
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: rgb(235, 242, 224);
  }
  /* Padding and font style */

  .table-trace td,
  .table-trace th {
    padding: 5px 10px;
    font-size: 12px;
    font-family: Verdana;
    color: rgb(149, 170, 109);
  }
  /* Alternating background colors */

  .table-trace tr:nth-child(even) {
    background: rgb(230, 238, 214)
  }

  .table-trace tr:nth-child(odd) {
    background: rgb(230, 238, 214)
  }

</style>
